<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="top">

        </ui:define>

        <ui:define name="left">

        </ui:define>
        <ui:define name="content">


            <h:form prependId="false" id="form" >   

                <p:messages/>
                <h:dataTable value="#{rawMaterialQuotationController.selectedRawMaterial}" var="pqp" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="Product"/>
                        </f:facet>
                        <h:outputText value="#{pqp.productName}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="Quantity "/>
                        </f:facet>
                        <p:inputText value="#{rawMaterialQuotationController.quantity}"/>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                            <h:outputText value="Receive Quotation until:"/>
                        </f:facet>
                        <p:calendar value="#{rawMaterialQuotationController.validity}" mindate="#{rawMaterialQuotationController.getToday()}"/>
                    </h:column>
                </h:dataTable>

                <p:separator /> 

                <p:panel header="All Source Supply">
                    <p:dataTable value="#{rawMaterialQuotationController.vendors}" var="vpp"
                                 paginator="true" rows="30"  
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="30,50,100">
                        <p:column filterBy="#{vpp.companyName}" sortBy="#{vpp.companyName}">
                            <f:facet name="header">
                                <h:outputText value="Supplier"/>
                            </f:facet>
                            <h:outputText value="#{vpp.companyName}"/>
                        </p:column>

                        <p:column sortBy="#{rawMaterialQuotationController.selectedRawMaterial.productName}">  
                            <f:facet name="header">  
                                <h:outputText value="Raw Material " />  
                            </f:facet>  
                            <h:outputText value="#{rawMaterialQuotationController.selectedRawMaterial.productName}" />  
                        </p:column>

                        <p:column filterBy="#{vpp.star}" sortBy="#{vpp.star}">
                            <f:facet name="header">
                                <h:outputText value="Reliability point of this vendor(based on past order)"/>
                            </f:facet>
                            <h:outputText value="#{vpp.star}"/>
                              <h:outputText value="/5.0" />
                        </p:column>


                        <p:column style="width:32px"> 
                            <f:facet name="header">
                                <h:outputText value="Add"/>
                            </f:facet>
                            <p:commandButton value="Add" update="books msgs @parent" process="@this" >

                                <f:setPropertyActionListener value="#{vpp}"  
                                                             target="#{rawMaterialQuotationController.selectedVpp}" />
                                <p:collector value="#{rawMaterialQuotationController.selectedVpp}"
                                             addTo="#{rawMaterialQuotationController.vppPurchaseList}" />
                            </p:commandButton>  
                        </p:column> 
                    </p:dataTable>

                </p:panel>
                <p:separator /> 

                <p:panel header="Send Raw Material Quotations to these vendors:">
                    <p:outputPanel id="books">  
                        <p:dataTable value="#{rawMaterialQuotationController.vppPurchaseList}" var="pur"  
                                     paginator="true" rows="30"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >


                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Supplier" />  
                                </f:facet>  
                                <h:outputText value="#{pur.companyName}" />  
                            </p:column>  
                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Raw Material" />  
                                </f:facet>  
                                <h:outputText value="#{rawMaterialQuotationController.selectedRawMaterial.productName}" />  
                            </p:column> 
                         <p:column filterBy="#{pur.star}" sortBy="#{pur.star}">
                            <f:facet name="header">
                                <h:outputText value="Reliability point of this vendor(based on past order)"/>
                            </f:facet>
                            <h:outputText value="#{pur.star}"/>
                               <h:outputText value="/5.0" />
                        </p:column>
                            <p:column>  
                                <f:facet name="header">  
                                    <h:outputText value="Operations" />  
                                </f:facet>  
                                <p:commandButton value="Remove" update="books msgs @parent" >
                                    <f:setPropertyActionListener value="#{pur}"  
                                                                 target="#{rawMaterialQuotationController.selectedVpp}" /> 
                                    <p:collector value="#{rawMaterialQuotationController.selectedVpp}"  
                                                 removeFrom="#{rawMaterialQuotationController.vppPurchaseList}" />  
                                </p:commandButton>  
                            </p:column>  

                        </p:dataTable>  
                    </p:outputPanel>  
                </p:panel>
                <br/>
                <p:commandButton action="#{rawMaterialQuotationController.createRMQuotation}" ajax="false" value="Send" update="growl"/>    
<p:commandButton action="PurchaseRequisition" ajax="false" value="Back" />    

            </h:form>    
        </ui:define>
    </ui:composition>



</html>